#include "imagelabel.h"
#include "reporteditor_global.h"

ImageLabel::ImageLabel(QWidget *parent) :
    QLabel(parent)
{
    setScaledContents(false);
    setAlignment(Qt::AlignCenter);
    setLineWidth(2);
    setFrameShape(QFrame::Panel);
    setFrameStyle(QFrame::Plain);
}

void ImageLabel::setPixmap(const QPixmap &pixmap)
{
    p = pixmap;
    QLabel::setPixmap(p.scaled(IMAGE_LABEL_SIZE, IMAGE_LABEL_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}

void ImageLabel::setImageSize(const QSize &size)
{
    QLabel::setPixmap(p.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}

void ImageLabel::mousePressEvent(QMouseEvent *e)
{
    setFrameStyle(QFrame::Sunken);
    emit labelPressed(this);
}

void ImageLabel::mouseDoubleClickEvent(QMouseEvent *e)
{
    setFrameStyle(QFrame::Sunken);
    emit labelActived(this);
}
